import './MyEntry.scss'

import React, { Component } from 'react';
import {index_nav } from '../../utils/api'
class MyEntry extends Component {
    constructor(props){
        super(props);
        this.state = { //定义在组件状态
            list:[]
        }
    }
    componentDidMount(){
        index_nav().then((res)=>{
            // console.log(res.data.list)
            this.setState(
                this.state.list = res.data.list
            )
        })
    }
    render() {
        return (
            <div className='list1'>
                {/* 列表渲染 使用js中的map函数 */}
                {
                    this.state.list.map((item,index)=>{
                        return (
                            <div className="cate" key={index}>
                                <img src={item.pic} />
                                <div className="name">{item.name}</div>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default MyEntry;